<?php
    require_once 'load.php';
    if (isLogin()) {
        redirect(admin_url());
           exit();
    }
    $action = isset($_REQUEST['action'])? $_REQUEST['action'] : NULL;
    if ($action) {
      if ($action == 'isLogin') {
          $user = user_logon();
          if ($user) {
           redirect(admin_url());
           exit();
          } else {
              redirect(BASE_URL . 'login.php');
              exit;
          }
      } 
    }
?>
<!DOCTYPE HTML>
<html lang="en-US">
<head>
	<meta charset="UTF-8">
	<title>Login Page</title>
        <link type="text/css" rel="stylesheet" href="<?php echo BASE_URL?>/admin/css/login.css"/>
        <script type="text/javascript" src="<?php echo BASE_URL?>/includes/js/jquery.js"></script>
</head>
<body>
    <form id="login" method="POST" action="login.php">
    <input type="hidden" name="action" value="isLogin"/>
    <h1>Log in with your account!</h1>
  

    <div>
    	<label for="login_username">Username</label>
    	<input type="text" name="username" id="login_username" class="field required" title="Please provide your username" />
    </div>

    <div>
    	<label for="login_password">Password</label>
    	<input type="password" name="password" id="login_password" class="field required" title="Password is required" />
    </div>

    <p class="forgot"><a href="<?php echo BASE_URL ?>/login.php?action=lostpassword">Forgot your password?</a></p>

    <div class="submit">
        <button type="submit">Log in</button>

        <label>
        	<input type="checkbox" name="remember" id="login_remember" value="yes" />
            Remember my login on this computer
        </label>
    </div>

    <p class="back"><a href="index.php">Go back to home</a></p>

</form>
</body>
</html>

